<?php
// .-----------------------------------------------------------------------------------
// | WE TRY THE BEST WAY
// |-----------------------------------------------------------------------------------
// | Author: 贝贝 <hebiduhebi@163.com>
// | Copyright (c) 2013-2015, http://www.gooraye.net. All Rights Reserved.
// |-----------------------------------------------------------------------------------
namespace Ucenter\Controller;

use Ucenter\Api\UcenterAppApi;

class UcenterAppController extends UcenterController{

    public function add(){
        if(IS_POST){

            $form = I('post.form','');
            $app_id = uniqid('by'.UID);
            $auth_key =  md5(uniqid());
            $form['app_id'] = $app_id;
            $form['auth_key'] = $auth_key;
            $api = new UcenterAppApi();

            $result = $api->add($form);

            if($result['status']){
                $this->success("添加成功",U('Ucenter/UcenterApp/index'));
            }else{
                $this->error($result['info']);
            }


        }else{

            $this->display();
        }
    }


	public function index(){
		$map = null;
		
		$page = array('curpage'=>I('get.p'),C('LIST_ROWS'));

        $api = new UcenterAppApi();
		$result = $api->query($map,$page);
		if($result['status']){
			$this->assign("list",$result['info']['list']);
			$this->assign("show",$result['info']['show']);
			$this->display();
		}
	}
	
	
	
}
